<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Form
 *
 * @author Lille
 */
class Koncept_Form extends Zend_Form
{

    protected $_overrideMethods = array('put', 'delete');
    /**
     * Set form method
     *
     * Only values in {@link $_methods()} allowed
     *
     * @param  string $method
     * @return Zend_Form
     * @throws Zend_Form_Exception
     */
    public function setMethod($method)
    {
        $method = strtolower($method);
        if (!in_array($method, $this->_methods)) {
            require_once 'Zend/Form/Exception.php';
            throw new Zend_Form_Exception(sprintf('"%s" is an invalid form method', $method));
        }
        if (in_array($method, $this->_overrideMethods)) {
            $this->setAttrib('method', 'post');
            if(!$override = $this->getElement('_method')) {
                $override = new Zend_Form_Element_Hidden('_method');
            }
            $override->setValue($method);
        } else {
            $this->setAttrib('method', $method);
        }
        return $this;
    }
}
?>
